package ch.fusun.baron.property.ui;

import ch.fusun.baron.map.ui.gef.editpart.TileChild;
import ch.fusun.baron.player.Dynasty;
import ch.fusun.baron.swt.isometry.components.Sprite;

/**
 * The property tile child (for borders)
 */
public class PropertyTileChild implements TileChild<Dynasty> {

	private final int index;

	/**
	 * @param i
	 *            the index
	 */
	public PropertyTileChild(int i) {
		this.index = i;
	}

	@Override
	public Dynasty getModel() {
		return null; // can't be selected anyway
	}

	@Override
	public Sprite getSprite() {
		return new Sprite(Activator.getBorderImage(index),
				Activator.getBorderImage(turn90(index)),
				Activator.getBorderImage(turn90(turn90(index))),
				Activator.getBorderImage(turn90(turn90(turn90(index)))), 15);
	}

	private static int turn90(int index) {
		return ((2 * (index & 15)) & 15) + ((index & 8) / 8);
	}

}
